<?php

namespace app\admin\service\traits;

use ShidianUtil\Utils\TimeUtil;

/**
 * Trait TuTrait
 * @package app\admin\service\traits
 */
trait TuTrait
{
    private function getTimes($startTime, $endTime): array
    {
        return TimeUtil::timeList(TimeUtil::DAY, $startTime, $endTime, true);
    }

    private function getX(array $times): array
    {
        $x = [];
        foreach ($times as $time) {
            $x[] = date('m-d', $time['s_time']);
        }
        return $x;
    }

    private function wrapTuItem(array $times, $kvs, $default = 0): array
    {
        $result = [];
        foreach ($times as $item) {
            $date = date('Y-m-d', $item['s_time']);
            $result[] = $kvs[$date] ?? $default;
        }
        return $result;
    }
}